<?php
/**
 * PhpStorm
 * User: zu
 * Date: 2019/2/25
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SmsLog extends Model
{
    protected $table = 'sms_log';

    /**
     * 添加短信日志记录
     * @param $phone 手机号
     * @param $msg 内容
     * @param $status 运营商返回的每个手机的发送状态码
     * @param $desc 状态描述
     * @param $operators 短信平台:1广泛模板平台2.阿里云
     * @param string $uuid 发送人id
     * @param int $send_source 发送的来源1.货窝子admin,2.货主pc端群发短信
     * @return bool
     *
     */
    public function addLog($phone, $msg, $status, $desc, $operators, $uid = '', $send_source = 1)
    {
        try {
            $data = [
                'phone' => $phone,
                'msg' => $msg,
                'status' => $status,
                'desc' => $desc,
                'operators' => $operators,
                'send_uid' => $uid,
                'send_source' => $send_source,
                'created_at' => date('Y-m-d H:i:s', time())

            ];
            $this->insert($data);
            return true;
        } catch (\Exception $e) {
            dd($e->getMessage());
            return false;
        }
    }
}